package com.css.fxfzypg.modules.earthquakedisasterloss.controller;

import com.css.fxfzypg.base.response.RestResponse;
import com.css.fxfzypg.modules.earthquakedisasterloss.service.CountMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: fxfzypg
 * @Author: lhl
 * @CreateDate: 2022/10/12 13:58
 */
@RestController
@Slf4j
@RequestMapping("/count")
public class CountMaterialController {

    @Resource
    CountMaterialService countMaterialService;

    @PostMapping("/countMaterial")
    public RestResponse countMaterial(@RequestParam String taskId, @RequestParam String modelId){
        RestResponse restResponse = null;
        try {
            restResponse =countMaterialService.countMaterial(taskId,modelId);
        }catch (Exception e){
            e.printStackTrace();
            restResponse = RestResponse.fail(503,"计算物资需求预估失败！");
        }
        return restResponse;
    }
}
